home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / pc / DirectX SDK / DXSDK / samples / Multimedia / DirectPlay / Maze / MazeCommon / MazeApp.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-10-31  |  5.0 KB  |  151 lines

  1. //----------------------------------------------------------------------------
  2. // File: mazeapp.h
  3. //
  4. // Desc: see main.cpp
  5. //
  6. // Copyright (c) 1999-2001 Microsoft Corp. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #ifndef _MAZE_APP_H
  9. #define _MAZE_APP_H
  10.  
  11.  
  12. #include "DPlay8Client.h"
  13. #include "MazeClient.h"
  14. #include "IMazeGraphics.h"
  15.  
  16. class   CDPlay8Client;
  17.  
  18. //-----------------------------------------------------------------------------
  19. // Defines, and constants
  20. //-----------------------------------------------------------------------------
  21. #define MAX_OUTPUT_QUEUE    256
  22. #define MICROSOFT_SERVER    TEXT("DirectPlayMaze.rte.microsoft.com")
  23. #define MAZE_REGKEYNAME     TEXT("Software\\Microsoft\\DirectPlayMaze\\MazeClient")
  24.  
  25. //-----------------------------------------------------------------------------
  26. // Dplay Defines, and constants
  27. //-----------------------------------------------------------------------------
  28. #define MIN_SP_THREADS      1
  29. #define MAX_SP_THREADS      128
  30. #define MAX_SP_BUFFER       1024000
  31.  
  32. //-----------------------------------------------------------------------------
  33. // Name: 
  34. // Desc: 
  35. //-----------------------------------------------------------------------------
  36. struct MazeConfig
  37. {
  38.     BOOL    bConnectToMicrosoftSite;
  39.     BOOL    bConnectToLocalServer;
  40.     BOOL    bConnectToRemoteServer;
  41.     DWORD   dwNetworkRetryDelay;
  42.     BOOL    bShowFramerate;
  43.     BOOL    bShowIndicators;
  44.     BOOL    bDrawMiniMap;
  45.     BOOL    bFullScreen;
  46.     BOOL    bReflections;
  47.     BOOL    bFileLogging;
  48.  
  49.     DWORD   dwSPThreads;
  50.     DWORD   dwSPBufferSize;
  51.  
  52.     DWORD   dwStressConnect;
  53.  
  54.     TCHAR   szIPAddress[64];
  55.  
  56.     DWORD   dwLogLevel;
  57.     DWORD   dwAutoPrintStats;
  58.     BOOL    bAutoDisconnnect;
  59.     BOOL    bAutoConnnect;
  60. };
  61.  
  62.  
  63. //-----------------------------------------------------------------------------
  64. // Name: 
  65. // Desc: 
  66. //-----------------------------------------------------------------------------
  67. class CMazeApp
  68. {
  69.  
  70. public:
  71.     CMazeApp();
  72.     ~CMazeApp();
  73.  
  74.     HRESULT Create( IMazeGraphics* pMazeGraphics );
  75.     int     Run( HINSTANCE hInst );
  76.     HRESULT FrameMove( FLOAT fElapsedTime );
  77.     void    ConsolePrintf( EnumLineType EnumLineType, const TCHAR* fmt, ... );
  78.     void    ReadConfig();
  79.     void    WriteConfig();
  80.     void    CreateTempLogFile();
  81.     void    CloseTempLogFile();
  82.  
  83.     MazeConfig* GetConfig() {return &m_Config; };
  84.  
  85.     TCHAR*  GetLogDir() { return m_strLogDir; };
  86.     TCHAR*  GetLogFile() { return m_strLogFile; };
  87.     BOOL    IsOutOfDateClient() { return m_bOutOfDateClient; };
  88.  
  89.     VOID    SetOutOfDateClient( BOOL bOutOfDateClient ) { m_bOutOfDateClient = bOutOfDateClient; };
  90.     VOID    SetAllowConnect(    BOOL bAllowConnect )    { m_bAllowConnect = bAllowConnect; };
  91.     VOID    SetSaveSettings(    BOOL bSaveSettings )    { m_bSaveSettings = bSaveSettings; };
  92.     VOID    SetConnectNow(      BOOL bConnectNow )      { m_bConnectNow = bConnectNow; };
  93.     VOID    SetDisconnectNow(   BOOL bDisconnectNow )   { m_bDisconnectNow = bDisconnectNow; };
  94.     VOID    SetAllowLoopback(   BOOL bAllowLoopback )   { m_bAllowLoopback = bAllowLoopback; };
  95.  
  96. protected:
  97.     static UINT WINAPI StaticOutputMsgThread( LPVOID pParam );
  98.     static UINT WINAPI StaticClientThread( LPVOID pParam );
  99.     UINT WINAPI     OutputMsgThread( LPVOID pParam );
  100.     UINT WINAPI     ClientThread( LPVOID pParam );
  101.  
  102.     void            SuspendPowerManagement();
  103.     BOOL            ParseCommandLine();
  104.  
  105.     HRESULT         StartSessionEnum();
  106.     HRESULT         InitServerForLoopback();
  107.     BOOL            TryToConnect();
  108.     void            UpdateTimeStamp();
  109.  
  110.     IMazeGraphics*      m_pMazeGraphics;
  111.     CDPlay8Client       m_DP8Client;
  112.     CMazeClient         m_MazeClient;
  113.     CMazeServer         m_MazeServer;
  114.     CDummyConnectorServer m_DummyServerConnection;
  115.     CDummyConnectorClient m_DummyClientConnection;
  116.  
  117.     MazeConfig          m_Config;
  118.  
  119.     HANDLE              m_hOutputMsgThread;
  120.     BOOL                m_bQuitThread;
  121.     HANDLE              m_hClientThread;
  122.     DWORD               m_dwNextOutputMsg;
  123.  
  124.     BOOL                m_bLocalLoopbackInitDone;
  125.     BOOL                m_bInitDone;
  126.  
  127.     BOOL                m_bAllowLoopback;
  128.     BOOL                m_bLocalLoopback;
  129.     BOOL                m_bAllowConnect;
  130.     BOOL                m_bConnectNow;
  131.     BOOL                m_bDisconnectNow;
  132.     BOOL                m_bOutOfDateClient;
  133.  
  134.     TCHAR               m_strTimeStamp[50];
  135.  
  136.     BOOL                m_bSaveSettings;
  137.  
  138.     CCriticalSection    m_OutputMsgQueueLock;
  139.     LONG                m_lQueueSize;
  140.     TCHAR               m_szOutputMsgBuffer[MAX_OUTPUT_QUEUE][256];
  141.     EnumLineType        m_EnumLineType[MAX_OUTPUT_QUEUE];
  142.     DWORD               m_dwNextFreeOutputMsg;
  143.     HANDLE              m_hOutputMsgEvent;
  144.     HANDLE              m_hLogFile;
  145.     TCHAR               m_strLogFile[MAX_PATH];
  146.     TCHAR               m_strLogDir[MAX_PATH];
  147. };
  148.  
  149.  
  150. #endif
  151.